<template>
  <el-card style="margin: 2vw;height: 86vh;overflow-y: auto;padding: 20px">
    <div class="up-card">
      <div>
        <el-dropdown>
          <el-button type="primary">
            项目<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item>项目一</el-dropdown-item>
            <el-dropdown-item>项目二</el-dropdown-item>
            <el-dropdown-item>项目三</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>

      <div>
        <el-popover placement="bottom" width="50" trigger="hover" style="overflow-y: auto;">
          <el-switch v-model="select.s1" active-text="项目名称" style="margin-bottom: 4px"></el-switch>
          <el-switch v-model="select.s2" active-text="项目类别" style="margin-bottom: 4px"></el-switch>
          <el-switch v-model="select.s3" active-text="项目时间" style="margin-bottom: 4px"></el-switch>
          <el-switch v-model="select.s4" active-text="项目背景" style="margin-bottom: 4px"></el-switch>
          <el-switch v-model="select.s5" active-text="技术需求" style="margin-bottom: 4px"></el-switch>
          <el-switch v-model="select.s6" active-text="项目成员" style="margin-bottom: 4px"></el-switch>
          <el-switch v-model="select.s7" active-text="执行计划" style="margin-bottom: 4px"></el-switch>
          <el-switch v-model="select.s8" active-text="项目风险" style="margin-bottom: 4px"></el-switch>
          <el-switch v-model="select.s9" active-text="项目周期" style="margin-bottom: 4px"></el-switch>
          <el-switch v-model="select.s10" active-text="成员贡献度" style="margin-bottom: 4px"></el-switch>
          <el-switch v-model="select.s11" active-text="项目进度" style="margin-bottom: 4px"></el-switch>
          <el-button type="primary" slot="reference">自定义报表</el-button>
        </el-popover>
      </div>

    </div>

    <div class="down-card">
      <div class="form-card">
        <el-form ref="form" :model="form" label-width="80px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="项目名称" v-show="select.s1">
                <el-input v-model="form.name" style="width: 20vw" :readonly="true"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="项目类别" v-show="select.s2">
                <el-input v-model="form.name" style="width: 20vw" :readonly="true"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-row>
                <el-form-item label="项目时间" v-show="select.s3">
                  <el-col :span="11">
                    <el-date-picker type="date" placeholder="选择日期" :readonly="true" v-model="form.date1"
                      style="width: 100%;"></el-date-picker>
                  </el-col>
                  <el-col class="line" :span="2">—</el-col>
                  <el-col :span="11">
                    <el-date-picker type="date" placeholder="选择日期" :readonly="true" v-model="form.date2"
                      style="width: 100%;"></el-date-picker>
                  </el-col>
                </el-form-item>
              </el-row>
            </el-col>
          </el-row>
          <el-form-item label="项目背景" v-show="select.s4">
            <el-input v-model="form.name" style="width: 20vw" :readonly="true"></el-input>
          </el-form-item>
          <el-form-item label="技术需求" v-show="select.s5">
            <el-input v-model="form.name" style="width: 20vw" :readonly="true"></el-input>
          </el-form-item>
          <el-form-item label="项目成员" v-show="select.s6">
            <el-input v-model="form.name" style="width: 20vw" :readonly="true"></el-input>
          </el-form-item>
          <el-form-item label="执行计划" v-show="select.s7">
            <el-input v-model="form.name" style="width: 20vw" :readonly="true"></el-input>
          </el-form-item>
          <el-form-item label="项目风险" v-show="select.s8">
            <el-input v-model="form.name" style="width: 20vw" :readonly="true"></el-input>
          </el-form-item>
        </el-form>
      </div>
    </div>

    <div class="maps">
      <div class="map1" v-show="select.s9">
        <chart1 ref="c1" :key="new Date().getTime()"></chart1>
      </div>
      <div class="map2" v-show="select.s10">
        <chart2 ref="c2" :key="new Date().getTime()"></chart2>
      </div>
      <div class="map3" v-show="select.s11">
        <chart3 ref="c3" :key="new Date().getTime()"></chart3>
      </div>
    </div>

    <el-button type="primary" @click="onSubmit, handleExport()"
      style="margin-left: 72vw;margin-top: 5vh;">立即下载</el-button>

  </el-card>
</template>

<script>
import { downloadPDF } from "./pdf"
import chart1 from './maps/projectCycle'
import chart2 from './maps/contribution_degree'
import chart3 from './maps/project_schedule.vue'
export default {
  name: 'Statement',
  data() {
    return {
      form: {
        name: '我是项目的名称',
        region: '',
        date1: '2023-7-21',
        date2: '2023-7-28',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },
      select: {
        s1: true,
        s2: true,
        s3: true,
        s4: true,
        s5: true,
        s6: true,
        s7: true,
        s8: true,
        s9: true,
        s10: true,
        s11: true
      }
    }
  },
  components: {
    chart1,
    chart2,
    chart3
  },
  methods: {
    onSubmit() {
      console.log('submit!');
    },
    handleExport() {
      downloadPDF(this.$refs.pdf)
    },
  },

}
</script>

<style scoped>
.up-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.down-card {
  margin: 5vh 0 0 0;
  width: 100%;

  display: flex;
  justify-content: center;
  align-items: center;
}

.down-card .form-card {
  width: 80%;
  height: 100%;
}

.down-card .line {
  text-align: center;
}

.maps {
  display: flex;
  margin-top: 5vh;
  height: 40vh;
}

.map1 {
  flex: 1;
}

.map2 {
  flex: 1;
}

.map3 {
  flex: 1;
}
</style>
